package com.supermarket.manage.common.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.supermarket.manage.common.validation.CheckGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 商品实体类
 *
 * @author: Faxon
 * @data: 2020/3/8
 */
@ApiModel(value = "Product:商品实体类")
@Data
@TableName("tb_product")
public class Product implements Serializable {

    private static final long serialVersionUID = -6969633838224584849L;
    /**
     * 商品主键
     */
    @ApiModelProperty(value = "商品主键")
    @TableId(type = IdType.ASSIGN_UUID)
    @NotBlank(message = "商品主键不能为空", groups = {CheckGroup.Update.class})
    private String pid;

    /**
     * 商品名称
     */
    @ApiModelProperty(value = "商品名称")
    @NotBlank(message = "商品名称不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private String pname;

    /**
     * 商品单位名称
     */
    @ApiModelProperty(value = "商品单位名称")
    @NotBlank(message = "商品单位名称不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private String unitName;

    /**
     * 成本价
     */
    @ApiModelProperty(value = "成本价")
    @NotNull(message = "成本价不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private BigDecimal costPrice;

    /**
     * 销售价
     */
    @ApiModelProperty(value = "销售价")
    @NotNull(message = "销售价不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private BigDecimal salePrice;

    /**
     * 会员价
     */
    @ApiModelProperty(value = "会员价")
    @NotNull(message = "会员价不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private BigDecimal vipPrice;

    /**
     * 预警值
     */
    @ApiModelProperty(value = "预警值")
    @NotNull(message = "预警值不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private Integer warnValue;

    /**
     * 库存数量
     */
    @ApiModelProperty(value = "库存数量")
    private BigDecimal stockNumber;

    /**
     * 一级分类id
     */
    @ApiModelProperty(value = "一级分类id")
    @NotNull(message = "一级分类id不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    @Length(min = 32, max = 32, message = "一级分类id错误（32位字符串）", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private String firstCid;

    /**
     * 二级分类id
     */
    @ApiModelProperty(value = "二级分类id")
    @NotNull(message = "二级分类id不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    @Length(min = 32, max = 32, message = "二级分类id错误（32位字符串）", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private String secondCid;

    /**
     * 三级分类id
     */
    @ApiModelProperty(value = "三级分类id")
    @NotNull(message = "二级分类id不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    @Length(min = 32, max = 32, message = "三级分类id错误（32位字符串）", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private String thirdCid;

    /**
     * 商品状态（0：上架，1：下架）
     */
    @ApiModelProperty(value = "商品状态（0：上架，1：下架）")
    private Integer status;

    /**
     * 商品图片地址
     */
    @ApiModelProperty(value = "商品图片地址")
    @NotNull(message = "商品图片不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private String pic;

    /**
     * 客户id
     */
    @ApiModelProperty(value = "客户id")
    @NotNull(message = "客户id不能为空", groups = {CheckGroup.Add.class, CheckGroup.Update.class})
    private String buyerId;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date created;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updated;
}
